//
// Created by 123 on 2025/1/10.
//
#include "vector"
#include "string"
#include "algorithm"
#include "iostream"

class GreaterFive{
public:
    bool operator()(int val){
        return val > 5;
    }
};

void test1(){
    std::vector<int> v;
    for (int i = 0; i < 10; ++i) {
        v.push_back(i);
    }
    std::vector<int>::iterator it =  std::find_if(v.begin(),v.end(),GreaterFive());
    if(it == v.end()){
        std::cout << "can not find" << std::endl;
    }else{
        std::cout << "get more than five numer" << std::endl;
    }
}

class Person{
public:
    std::string name;
    int age;

public:
    Person(std::string name,int age){
        this->name = name;
        this->age = age;
    }
};

class GreaterTen{
public:
    bool operator()(Person& p){
        return p.age > 10;
    }
};

void test2(){
    std::vector<Person> v;
    v.push_back(Person("zs",18));
    v.push_back(Person("ls",6));
    v.push_back(Person("ww",18));

    std::vector<Person>::iterator it =  std::find_if(v.begin(),v.end(),GreaterTen());
    it++;
    if(it == v.end()){
        std::cout << "can not found" << std::endl;
    }else{
        std::cout << "name=" << it->name << " age:" << it->age << std::endl;
    }

}

int main153(){
    test1();
    test2();
    return 0;
}